<?php

class Event {

    public $id;
    public $title;
    public $description;
    public $start;
    public $end;
    public $all_day;
    public $type_id;
    public $type_description;
    public $bg_color;
    public $text_color;

    public static function get_ISO8601_format($dt) {
        list ($date, $time) = explode(" ", $dt);
        return $date . "T" . $time . "Z";
    }

    public function get_html() {
        ?>
        <li><span class="label label-info"><?= $this->start->format('H:i') ?> > <?= $this->end->format('H:i') ?></span> <?= $this->title ?></li>
        <?php
    }

    public function get_start_end_time() {
        return $this->start->format('H:i');
    }

    public function get_style() {
        return 'label-' . $this->type_description;
    }

    public function get_list_html() {
        ?>
        <tr>
            <td><strong><?= $this->title ?></strong></td>
            <td><?= $this->description ?></td>
            <td><?= $this->start->format('d/m/Y - H:i') ?></td>
            <td><?= $this->end->format('d/m/Y - H:i') ?></td>
            <td><?= ($this->all_day) ? '<i class="icon-ok"></i>' : '<i class="icon-remove"></i>' ?></td>
            <td><?= $this->type_description ?></td>
            <td>
                <div class="btn-group">
                    <a class="btn" href="http://www.salesianichioggia.it/dashboard/event.php?action=edit&id=<?= $this->id?>"><i class="icon-pencil"></i></a>
                    <a class="btn btn-danger delete" href="http://www.salesianichioggia.it/dashboard/event.php?action=delete&id=<?= $this->id ?>"><i class="icon-trash"></i></a>
                </div>
            </td>
        </tr>
        <?php
    }

}
?>
